import { request } from "../utils";

// 登录接口
export const loginApi = (data) => {
  return request({
    method: "post",
    url: "/authorizations",
    data,
  });
};

// 获取个人信息接口
export const getUserInfoApi = (data) => {
  return request({
    method: "get",
    url: "/user/profile",
    data,
  });
};

// 获取频道列表接口
export const getChannelApi = () => {
  return request({
    method: "get",
    url: "/channels",
  });
};

// 提交文章表单接口
export const addArticlesApi = (data) => {
  return request({
    method: "post",
    url: "/mp/articles?draft=false",
    data,
  });
};

// 获取文章列表接口
export const getArticlesListApi = (params) => {
  return request({
    method: "get",
    url: "/mp/articles",
    params,
  });
};

// 删除文章接口
export const deleteArticlesApi = (id) => {
  return request({
    method: "delete",
    url: `/mp/articles/${id}`,
  });
};

// 获取文章详情接口
export const getArticlesDetailApi = (id) => {
  return request({
    method: "get",
    url: `/mp/articles/${id}`,
  });
};

// 获取文章详情接口
export const editArticlesDetailApi = (id, data) => {
  return request({
    method: "put",
    url: `/mp/articles/${id}`,
    data,
  });
};
